import 'package:eye_flutter_app/demo/Button/ButtonExtend.dart';
import 'package:eye_flutter_app/demo/ChartsFlutter/ChartsFlutter.dart';
import 'package:eye_flutter_app/demo/FlChart/FlChart.dart';
import 'package:eye_flutter_app/demo/CheckBox.dart';
import 'package:eye_flutter_app/demo/HttpDemo.dart';
import 'package:eye_flutter_app/demo/IconDemo.dart';
import 'package:eye_flutter_app/demo/ProviderDemo.dart';
import 'package:eye_flutter_app/demo/Radio.dart';
import 'package:eye_flutter_app/demo/StoragePage.dart';
import 'package:eye_flutter_app/demo/TablePage.dart';
import 'package:eye_flutter_app/demo/TextField.dart';
import 'package:eye_flutter_app/pages/cart.dart';
import 'package:eye_flutter_app/pages/demo.dart';
import 'package:eye_flutter_app/pages/home.dart';
import 'package:flutter/material.dart';

//配置路由
final Map<String, Function> routes = {
  '/': (context) => HomePage(),
  '/textField': (context) => TextFieldDemoPage(),
  '/checkbox': (context) => CheckBoxDemo(),
  '/radio': (context) => RadioDemo(),
  '/button': (context) => ButtonExtendDemoPage(),
  '/flChart': (context) => FlChartDemo(),
  '/chartsFlutter': (context) => ChartsFlutterPage(),
  '/table': (context) => TablePage(),
  '/icon': (context) => IconDemo(),
  '/demo': (context) => DemoPage(),
  '/http': (context) => HttpDemo(),
  '/storage': (context) => StoragePage(),
  '/provider': (context) => ProviderDemo(),
  '/cart': (context) => CartPage(),
};

//固定写法
var onGenerateRoute = (RouteSettings settings) {
  final String? name = settings.name;
  final Function? pageContentBuilder = routes[name];
  if (pageContentBuilder != null) {
    if (settings.arguments != null) {
      final Route route = MaterialPageRoute(
          builder: (context) =>
              pageContentBuilder(context, arguments: settings.arguments));
      return route;
    } else {
      final Route route =
          MaterialPageRoute(builder: (context) => pageContentBuilder(context));
      return route;
    }
  }
};
